package com.ichengzi.audit.human.api.live.remote.factory;

import com.ichengzi.audit.human.api.live.domain.LiveAuditTask;
import com.ichengzi.audit.human.api.live.remote.RemoteLiveAuditTaskService;
import com.ichengzi.audit.human.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 任务获取接口
 *
 * @author lihn
 */
@Component
public class RemoteLiveAuditTaskFactory implements FallbackFactory<RemoteLiveAuditTaskService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteLiveAuditTaskFactory.class);

    @Override
    public RemoteLiveAuditTaskService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteLiveAuditTaskService() {
            @Override
            public R<LiveAuditTask> getLiveAuditTask(String taskName) {
                return R.fail("获取用户失败:" + throwable.getMessage());
            }
        };
    }
}
